CC = gcc
CFLAGS = -std=c11 -Wall -Wextra -pedantic -O2 \
         $(shell pkg-config --cflags sdl2 SDL2_ttf) \
         -I/usr/local/include

LDFLAGS = $(shell pkg-config --libs sdl2 SDL2_ttf) \
          -L/usr/local/lib \
          -lavformat -lavcodec -lswscale -lswresample -lavutil \
          -lm -lz

TARGET = video
SRC = video_linux.c
OBJ = $(SRC:.c=.o)

.PHONY: all clean check-deps run

all: check-deps $(TARGET)

$(TARGET): $(OBJ)
	$(CC) $^ -o $@ $(LDFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJ) $(TARGET)

run:
	./video


